﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using TreeExtensions;
using System.Xml.Linq;

namespace LinqToVisualTree
{
  /// <summary>
  /// Interaction logic for Window1.xaml
  /// </summary>
  public partial class Window1 : Window
  {
    public Window1()
    {
      InitializeComponent();

     /* IEnumerable<TextBox> boxes = LayoutRoot.Descendants<TextBox>()
                        .Where(i => i.Ancestors().Take(1).Single() is StackPanel);

      var foo = LayoutRoot.Descendants()
          .Where(i => i is StackPanel)          
          .Descendants<TextBox>()
          .Select(i => i.Name);

      var bar = new List<StackPanel>();

      var g = new Bar<DependencyObject>();*/

     // foo = LayoutRoot.Descendants();

      var ffoo = LayoutRoot.Descendants().Where(i => i is TextBox).Cast<TextBox>();

        var foo = new List<object>();

        foo.Cast<string>().Single();

     // var doc = XDocument.Load("Window1.xml");
   //   var fooPie = doc.Descendants("StackPanel").Descendants("TextBox");
    }
  }

  public class Bar<T> where T : DependencyObject
  {
  }
}
